package cn.elead.it.sso.system.service.impl;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.gitee.domain.CustomMailMessage;
import com.gitee.service.ISubjectAttachService;

@Service
public class EmailAttachService implements ISubjectAttachService {

	@Override
	public void loadSubjectContext(CustomMailMessage message) {

		// 通过subjectId获取邮件主题和模板
		message.setSubject("易立德 | 重置密码信息");
		// String content = "<html>\n" + "<body>\n" + "
		// <h3>您好${name},这是验证邮件,请点击下面的链接完成验证!</h3>\n" + "</body>\n" + "</html>";
		String content = "<html>\n" + "<body>\n"
				+ "    <h3>您好${name},请勿回复本邮件,点击下面的链接,重设密码,本邮件超过30分钟,链接将会失效，需要重新申请找回密码!</h3><br/>"
				+ "<a href=\"${link}\">${link}</a>\n" + "</body>\n"
				+ "</html>";
		 message.setText(content);

	}

	@Override
	public void loadAttachment(CustomMailMessage message) {

		Map<String, File> attachments = new HashMap<String, File>();

		// 添加附件
		File qrCode = new File("wxgzh8cm.jpg");
		// 建议文件带上后缀，可支持在线预览
		attachments.put("公众号二维码.jpg", qrCode);

		message.setAttachments(attachments);

	}

	@Override
	public void loadResource(CustomMailMessage message) {
		// TODO Auto-generated method stub
	}

}
